package com.jdew.thkj.fragment;

import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.jdew.thkj.R;
import com.jdew.thkj.base.BaseFragment;

import butterknife.Bind;

public class TBOrderFragment extends BaseFragment {

    @Bind(R.id.tab)
    TabLayout tab;
    @Bind(R.id.th_viewpager)
    ViewPager viewpager;
    private String ordersource="tb";

    @Override
    protected int getContentViewId() {
        return R.layout.fragment_tborder;
    }

    @Override
    protected void onCreateViewT() {
        ShortPagerAdapter adapter = new ShortPagerAdapter(getChildFragmentManager());
        viewpager.setAdapter(adapter);
        tab.setupWithViewPager(viewpager);
    }

    @Override
    public void initData() {

    }

    private class ShortPagerAdapter extends FragmentPagerAdapter {
        public String[] mTilte = null;

        public ShortPagerAdapter(FragmentManager fm) {
            super(fm);
            mTilte = getResources().getStringArray(R.array.tab_order_Title);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mTilte[position];
        }

        @Override
        public BaseFragment getItem(int position) {
            BaseFragment fragment = FragmentFactory.createFragment4(position,ordersource);
            return fragment;
        }

        @Override
        public int getCount() {
            return mTilte.length;
        }
    }
}
